package com.muyu.user.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import lombok.Data;
import java.io.Serial;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;
import lombok.experimental.SuperBuilder;
import com.muyu.user.domain.model.SysUserGroupSaveModel;
import com.muyu.user.domain.model.SysUserGroupEditModel;
import com.muyu.common.core.web.domain.BaseEntity;

/**
 * 用户分组数据库映射对象 sys_user_group
 *
 * @author liuguoqiang
 * @date 2025-09-14
 */
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_user_group")
@EqualsAndHashCode(callSuper = true)
public class SysUserGroup extends BaseEntity {
    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 分组ID
     */
    @Excel(name = "分组ID")
    @TableId(value = "group_id",type = IdType.AUTO)
    private Long groupId;

    /**
     * 分组名称
     */
    @Excel(name = "分组名称")
    private String groupName;

    /**
     * 分组编码
     */
    private String groupCode;

    /**
     * 分组描述
     */
    private String description;

    /**
     * 排序
     */
    private Long sortOrder;

    /**
     * 状态（0正常 1停用）
     */
    private String status;

    /**
     * 添加构造器
     */
    public static SysUserGroup saveModelBuild(SysUserGroupSaveModel saveModel){
        return SysUserGroup.builder()
            .groupId(saveModel.getGroupId())
            .groupName(saveModel.getGroupName())
            .groupCode(saveModel.getGroupCode())
            .description(saveModel.getDescription())
            .sortOrder(saveModel.getSortOrder())
            .status(saveModel.getStatus())
            .build();
    }

    /**
     * 修改构造器
     */
    public static SysUserGroup editModelBuild(SysUserGroupEditModel editModel){
        return SysUserGroup.builder()
            .groupId(editModel.getGroupId())
            .groupId(editModel.getGroupId())
            .groupName(editModel.getGroupName())
            .groupCode(editModel.getGroupCode())
            .description(editModel.getDescription())
            .sortOrder(editModel.getSortOrder())
            .status(editModel.getStatus())
            .build();
    }

}
